<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="div1">
        <div>
            <span>
                <em>
                    4567
                </em>
            </span>
            <div>8888</div>
        </div>
    </div>
    <script>
        function getChildren(dom, n) {
            if (n < 1) {
                return dom.innerHTML
            } else if (n == 1) {
                let result = []
                for(let i=0;dom.children&&i<dom.children.length;i++){
                    result.push(dom.children[i].innerHTML);
                }              
                return result;
            } else {
                let result = []
                for(let i=0;dom.children&&i<dom.children.length;i++){
                    result.push(...getChildren(dom.children[i],n-1));
                };
                return result
            }
        }
        console.log(getChildren(document.body,3));
    </script>
</body>

</html>